package Leetcode;

import java.util.Arrays;
import java.util.Comparator;

public class problem452 {
    public static int findMinArrowShots(int[][] points) {
        if (points.length == 0) {
            return 0;
        }

        Arrays.sort(points, new Comparator<int[]>() {
            @Override
            public int compare(int[] ints, int[] t1) {
                return ints[1] - t1[1];
            }
        });

        int cnt = 1, end = points[0][1];
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] <= end) {
                continue;
            }
            cnt++;
            end = points[i][1];
        }
        return cnt;
    }

    public static void main(String[] args) {
        int[][] a = new int[][]{{10,16}, {2,8}, {1,6}, {7,12}};
        findMinArrowShots(a);

    }
}
